package homework;

/**
 * @Author Stringzhua
 * @Date 2024/2/29 21:23
 * description:定义Music类,里面有音乐名name,音乐时长times属性
 * 并有播放play功能和返回本身属性信息的功能方法getInfo
 */
public class homework09 {
    public static void main(String[] args) {
        Music music = new Music("城府",126);
        music.playMusic();
        System.out.println(music.getInfo());
    }
}
class Music{
    String name;
    int times;
    public Music(String name,int times){
        this.name=name;
        this.times=times;
    }
    public void playMusic(){
        System.out.println("音乐是" + this.name + "正在播放中...时长为" + this.times + "s");
    }
    public String getInfo(){
        return "音乐是" + name + "时长为" + times + "s";
    }
}
